package com.pandora.templating;

import java.util.Vector;
import com.pandora.model.BuildingBlock;
import com.pandora.model.ParameterTable;
import com.pandora.model.Task;

public class TaskTemplate extends BuildingBlockTemplate<Task> {

	public TaskTemplate(String name) {
		this(name,null);
	}
	
	public TaskTemplate(String name, String description) {
		super(name,description);
	}
	
	@Override
	protected Task createInstance() {
		Task task = new Task(this.name, this.description);
		ParameterTable<?> inParams = this.inParameters.getInstance();
		task.setInParameters(inParams);
		ParameterTable<?> outParams = this.outParameters.getInstance();
		task.setOutParameters(outParams);
		Vector<BuildingBlock> dependencies = new Vector<BuildingBlock>();
		Vector<BuildingBlockTemplate<? extends BuildingBlock>> dependTemplates = this.getDependencies();
		for (BuildingBlockTemplate<?> dependTemplate : dependTemplates) {
			BuildingBlock depend = dependTemplate.getInstance();
			dependencies.add(depend);
		}
		task.setDependencies(dependencies);
		return task;
	}


}
